const fs = require('fs');

// 读取
const files = fs.readdirSync(__dirname);
// 遍历数组
files.forEach(item=>{
    //判断
    let data = item.split('-');
    let [num,name] = data;
    let fileData =  name.split('.');
    let [newFileName,file] = fileData;
    if(Number(num) < 10) {
        num = '0'+parseInt(num);
    }
    // 创建新的文件名
    let newName = num+'-'+newFileName+'.'+file;
    console.log(newName)
    // // 重命名
    fs.renameSync(`${__dirname}/${item}`,`${__dirname}/${newName}`);
})